package com.bindingfly.client.formrender.widget.impl;

import java.util.HashMap;

import com.bindingfly.client.formrender.WidgetInjecterPojo;
import com.bindingfly.client.formrender.widget.types.InjectableWidget;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.Widget;

public class TextAreaFly implements InjectableWidget
{

	@Override
	final public Widget init(Element seedElement)
	{
		TextArea widget = new TextArea();
		
		String width = seedElement.getAttribute("widgetWidth");
		if (width != null && width.length() > 0)
		{
			widget.setWidth(width);
		}

		String height = seedElement.getAttribute("widgetHeight");
		if (height != null && height.length() > 0)
		{
			widget.setHeight(height);
		}

		String readOnly = seedElement.getAttribute("widgetReadOnly");
		if (readOnly != null)
		{
			widget.setReadOnly(readOnly.equals("true"));
		}

		return widget;
	}

	@Override
	public boolean doesRequirePostProcessExecution()
	{
		return false;
	}

	@Override
	public void executePostProcess(Widget widget, HashMap<String, WidgetInjecterPojo> renderedWidgets)
	{
		// TODO Auto-generated method stub
		
	}

	@Override
	public String getSubmitableValue(Widget widget)
	{
		TextArea textArea = (TextArea)widget;
		return textArea.getValue();
	}

}
